package com.zy.db.odbc;

import com.zy.common.core.constant.CharacterCon;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

@Data
public class OdbcConnectParam implements Serializable {

    @NotBlank(message = "IP地址不能为空")
    private String addr;

    @NotBlank(message = "端口不能为空")
    private String port;

    @NotBlank(message = "账号不能为空")
    private String accountName;

    @NotBlank(message = "密码不能为空")
    private String accountPassword;

    @NotBlank(message = "连接类型不能为空")
    private String connectType;

    @NotBlank(message = "库名不能为空")
    private String databaseName;

    public String getUrl() {
        return String.format(CharacterCon.JDBC_URL, this.connectType, this.getAddr(), this.port, this.databaseName);
    }

    public OdbcConnectParam configConnect() {
        this.setAddr("101.200.88.189");
        this.setPort("3306");
        this.setConnectType("mysql");
        this.setDatabaseName("test_db");
        this.setAccountName("root");
        this.setAccountPassword("zY000000...");
        return this;
    }

}


